﻿
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <title>防伪查询系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script language="javascript" type="text/javascript" src="jquery-1.4.2.js"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $("#btnQuery").click(function() {

                var $FwCode = $("#FwCode");

                var $CheckResult = $("#ReturnResult");

                var RegNumber = /^[0-9]*[1-9][0-9]*$/;
                var flag = false;



                $CheckResult.html("");


                if ($FwCode.val().length == 0) {

                    $CheckResult.html("防伪码不能为空");

                    $FwCode.focus();

                    return false;

                }

                else if ($FwCode.val().length < 10) {

                   $CheckResult.html("防伪码长度不能少于10位");
		 
                    $FwCode.focus();

                    return false;

                }

                else if ($FwCode.val().length > 24) {

                    $CheckResult.html("防伪码长度不能大于24位");

                    $FwCode.focus();

                    return false;

                }

                else if (!RegNumber.test($FwCode.val())) {

                   $CheckResult.html("您输入的防伪码不是数字");
  
                    $FwCode.focus();

                    return false;

                }

            
				
                $CheckResult.html("正在查询......");

                $(this).attr("disabled", true);

                var $strurl="" ;

           	$.ajaxSetup({ scriptCharset: "gbk" , contentType: "application/json; charset=gbk"});

 
                   $.getJSON(

                     "http://fw.582315.com/fwqueryjson.ashx?callback=?",
                    { FwCode: $FwCode.val() },

                    function(data) {

                  //    alert(data.CodeState);  //CodeState 为查询状况：0 错误 1 正确; 2 重复  
 
                 //     alert(data.QueryResult) ;   //QueryResult 查询结果 



                        $CheckResult.html(data.QueryResult);
                        setTimeout(btnEnabled, 2000);

                    });


 


            });



            function btnEnabled() {

                $("#btnQuery").attr("disabled", false);

            }


        });

    </script>

</head>
<body>
    <table width="576" height="90" border="0" align="center" cellpadding="0" cellspacing="0"
        bordercolorlight="#000000" bordercolordark="#CCCCFF">
        <tr>
            <td height="25" colspan="0" valign="top">
            </td>
        </tr>
        <tr>
            <td height="30" colspan="0" valign="middle">
                <div id="idDiv">
                    <div id="ReturnResult" style="font-size: 12px">
                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td height="30" width="100%" valign="top">
                <div class="fwcode">
                    请输入20位防伪码：<input type="text" name="FwCode" id="FwCode" maxlength="28" />
                    <input type="button" name="btnQuery" id="btnQuery" class="btnQuery" value="查询" /> 
                </div>
            </td>
        </tr>
    </table>
</body>
</html>
